#ifndef __SUBSYSTEM_WOOD_BLOCK_BEHAVIOR_H__
#define __SUBSYSTEM_WOOD_BLOCK_BEHAVIOR_H__

#include <set>
#include <mutex>
#include "Engine/Point3.hpp"
#include "Subsystems/BlockBehaviors/SubsystemBlockBehavior.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    class SubsystemGameInfo;
    class SubsystemTimeOfDay;
    class SubsystemTerrain;

    // 树叶自动消失行为
    class SubsystemWoodBlockBehavior : public SubsystemBlockBehavior
    {
    protected:
        SubsystemGameInfo *m_gameInfo;
        SubsystemTimeOfDay *m_timeOfDay;
        SubsystemTerrain *m_terrain;

        std::set<Point3> m_leavesToCheck;
        std::mutex m_leavesToCheckMutex;

    public:

        void decayLeavesIfNeeded(const std::vector<Point3> &pointVec);

        virtual void onBlockRemoved(int32_t value, int32_t newValue, int32_t x, int32_t y, int32_t z) override;
        virtual void onChunkDiscarding(TerrainChunk *chunk) override;

        virtual void update(float dt) override;
        virtual void load(const nlohmann::json& json) override;
        virtual void save(nlohmann::json& json) override;

        virtual const std::string& getName() const override;
        virtual SubUpdateType getUpdateType() override;
        
    };
    
}

#endif
